package com.zx.test23SDK.MyView;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Created by zhoux on 2018/2/8.
 * 注释：
 */

public class TestView extends LinearLayout {
    public TestView(Context context) {
        super(context);
        initview();
    }

    public TestView(Context context,AttributeSet attrs) {
        super(context, attrs);
    }

    private void initview() {
        TextView testView = new TextView(getContext());
        testView.setText("213");
        testView.setTextSize(32);
        testView.setGravity(Gravity.CENTER);
        testView.setBackgroundColor(0x33ffff00);
        addView(testView, 300, 300);
    }

    @Override
    protected void onFinishInflate() {
        Log.e("TestView", getMeasuredWidth() + "   onFinishInflate");
        super.onFinishInflate();
        initview();

    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        Log.e("TestView", getMeasuredWidth() + "   onMeasure");
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        Log.e("TestView", getMeasuredWidth() + "   onSizeChanged");

        super.onSizeChanged(w, h, oldw, oldh);
        // TODO: 2018/2/8

    }

//    @Override
//    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
//        Log.e("TestView", getMeasuredWidth() + "   onLayout");
////        super.onLayout(changed, left, top, right, bottom);
//    }

    @Override
    protected void onDraw(Canvas canvas) {
        Log.e("TestView", getMeasuredWidth() + "   onDraw");
        super.onDraw(canvas);
    }


}
